<template>
    <view class="content">
        <u-navbar back-icon-color="#000" title-color="#000" :border-bottom="false" title="详情" :background="background"></u-navbar>
        
        <image v-if="data.album_uri_txt" :src="data.album_uri_txt" class="bgx"></image>
        
        <view v-if="data.album_uri_txt" style="height:350rpx;position: relative;"></view>
        
        <view class="contm">
            <image :src="data.image_uri_txt" class="pic"></image>
            <view class="msg_ctn">
                <view class="shop_name u-line-1">{{data.title}}</view>
                <view class="iden" v-if="data.designation">
                    <view class="zzx">
                        <image src="@/static/icon/tex.png" class="ico"></image>
                    </view>
                    <text class="ttx">{{data.designation}}</text>
                </view>
            </view>
        </view>

        <view class="locx">
            <view class="zor">
                <view class="lex">
                    <view class="ttx">
                        <image src="@/static/icon/iiix3.png" class="ico"></image>
                        <text class="tt">联系方式</text>
                    </view>
                    <view class="ttpx">{{data.telephone}}</view>
                </view>
                <image src="@/static/icon/telx.png" class="pic" @click="goTel(data.telephone)"></image>
            </view>
            <view class="zor">
                <view class="lex">
                    <view class="ttx">
                        <image src="@/static/icon/iiix4.png" class="ico"></image>
                        <text class="tt">地址</text>
                    </view>
                    <view class="ttpx u-line-1">{{data.address}}</view>
                </view>
                <image src="@/static/icon/locx.png" class="pic" @click="toGuide"></image>
            </view>
        </view>

        <view class="rrz" v-if="data.flair || data.describe">
            <view class="tt" v-if="data.flair">资质</view>
            <view class="tzr u-p-b-30" v-if="data.flair">{{data.flair}}</view>
            
            <view class="tt" v-if="data.describe">商家介绍</view>
            <view class="tzr" v-if="data.describe">{{data.describe}}</view>
        </view>
        
        <view v-if="data && data.goods && data.goods.length > 0">
            <view class="titl">推荐商品</view>
            <goods :list="data.goods"></goods>
        </view>
    </view>
</template>

<script>
    import goods from '@/components/goodx'
    export default {
        components: {
            goods
        },
        data() {
            return {
                background: { backgroundColor: 'rgba(255,255,255,0)' },
                id: '',
                data: {},
                isShow: false,
            };
        },
        onLoad(option) {
            this.id = option.id
            this.getData()
        },
        methods: {
			goTel(t) {
				this.$call(t)
			},
			
            //导航
            toGuide() {
				if (!uni.getStorageSync('userToken')) {
				    this.$confirm('请先登录并且绑定手机号，是否去登录？',()=>{
				        uni.navigateTo({
				            url: "/pages/login/login"
				        })
				    })
				} else {
					uni.openLocation({
					    latitude: Number(this.data.lat),
					    longitude: Number(this.data.lng),
					    address: this.address,
					    success: (res) => {
					        console.log('success');
					    },
					    fail: (err) => {
					        console.log(err)
					        this.$toast('导航失败，请重试！')
					    }
					});
				}
            },
            
            getData() {
            	this.$ajax('serviceInfo', {
            		userToken: this.$getSync('userToken'),
            		id: this.id, //商品id
            	}).then(ret => {
            		if (ret.status == 0) {
                        this.data = ret.data.info
            			this.isShow = true;
            		} else {
            			this.$toast(ret.message);
            		}
            	});
            },
            
            onPageScroll: function(e) {
            	//nvue暂不支持滚动监听，可用bindingx代替
            	// console.log("滚动距离为：" + e.scrollTop);
            	let a = e.scrollTop * 0.05;
            	if (a > 1) {
            		a = 1;
            	}
            	if (e.scrollTop == 0) {
            		this.background.backgroundColor = 'rgba(0,0,0,0)';
            	} else {
            		this.background.backgroundColor = 'rgba(0,0,0,' + a + ')';
            	}
            },
        }
    };
</script>

<style scoped lang="scss">
    .content {
        min-height: 100vh;
        background: #f5f5f5;
    }

    .bgx {
        width: 750rpx;
        height: 796rpx;
        position: absolute;
        left: 0;
        top: 0;
    }

    .contm {
        width: 700rpx;
        border-radius: 18rpx;
        background: #fff;
        position: relative;
        height: 200rpx;
        display: flex;
        padding: 30rpx 26rpx;
        margin: 0 auto 20rpx;

        .pic {
            width: 140rpx;
            height: 140rpx;
            border-radius: 18rpx;
            margin-right: 28rpx;
        }

        .msg_ctn {
            flex: 1;
            width: 0;

            .shop_name {
                font-size: 32rpx;
                color: #000000;
                line-height: 56rpx;
                font-weight: 700;
            }

            .iden {
                display: flex;
                width: 156rpx;
                height: 40rpx;
                background: #feefef;
                border-radius: 4rpx;
                margin-bottom: 12rpx;

                .zzx {
                    width: 40rpx;
                    height: 40rpx;
                    border: 4rpx 0 0 4rpx;
                    background: linear-gradient(to right, #fe601d, #ff2a25);
                    display: flex;
                    align-items: center;
                    justify-content: center;

                    .ico {
                        width: 13rpx;
                        height: 24rpx;
                        display: block;
                    }
                }

                .ttx {
                    font-size: 24rpx;
                    color: #ff2825;
                    text-indent: 6rpx;
                    height: 40rpx;
                    line-height: 40rpx;
                }
            }
        }
    }

    .locx {
        height: 220rpx;
        width: 700rpx;
        background: #fff;
        border-radius: 18rpx;
        margin: 0 auto 20rpx;
        position: relative;
        padding: 6rpx 26rpx;

        .zor {
            display: flex;
            justify-content: space-between;
            height: 94rpx;
            align-items: center;

            .lex {
                flex: 1;
                width: 0;
                padding-top: 20rpx;
                height: 94rpx;
                padding-right: 20rpx;

                .ttx {
                    display: flex;
                    align-items: center;
                    height: 30rpx;
                    line-height: 30rpx;

                    .ico {
                        width: 18rpx;
                        height: 22rpx;
                        margin-right: 10rpx;
                    }

                    .tt {
                        font-size: 22rpx;
                        color: #fe8a00;
                    }
                }

                .ttpx {
                    font-size: 24rpx;
                    color: #333333;
                    line-height: 40rpx;
                }
            }

            .pic {
                width: 54rpx;
                height: 54rpx;
            }
        }
    }

    .rrz {
        width: 700rpx;
        background: #fff;
        margin: 0 auto 20rpx;
        border-radius: 18rpx;
        padding: 26rpx;

        .tt {
            font-size: 28rpx;
            color: #000000;
            font-weight: 700;
            margin-bottom: 10rpx;
        }

        .tzr {
            font-size: 24rpx;
            color: #666666;
        }
    }

    .titl {
        width: 700rpx;
        margin: 0 auto;
        height: 84rpx;
        line-height: 84rpx;
        font-weight: 700;
        font-size: 34rpx;
    }

    .goods_list {
        width: 700rpx;
        margin: 0 auto;
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
    }
</style>